using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

public class LevelCompletePage : UIPanel
{
    [SerializeField]
    private Text text;
    void Awake()
    {
        UIManager.Instance.AddPanel(PanelId.LevelComplete, this);
    }
    public override void Show()
    {
        AdManager.Instance.ShowNative();
        text.text = "第" + (Main.Instance.saveData.LevelIndex + 1) + "关";
        transform.DOScale(1f, 0f);
        base.Show();
    }
    public override void Hide()
    {
        transform.DOScale(0f, 0f);
        base.Hide();
    }
    public void OnClickNormalReward()
    {
        Main.Instance.saveData.ChangeCoin(Main.Instance.saveData.LevelIndex * 200);
        Hide();
        Main.Instance.DestoryOldScene();
        Main.Instance.CreateNewScene();
        Sequence sequence = DOTween.Sequence();
        sequence.Append(text.transform.DOMoveY(text.transform.position.y - (Screen.height / 2), 2.5f).SetEase(Ease.OutQuad));
        sequence.AppendInterval(1f);
        sequence.Append(text.transform.DOMoveY(text.transform.position.y, 2f).SetEase(Ease.InQuad));
        sequence.OnComplete(() =>
        {
            UIManager.Instance.CreateOrOpen(PanelId.MainMenu);
        });
    }
    public void OnClickDoubleReward()
    {
        AdManager.Instance.ShowVideo(() =>
        {
            Main.Instance.saveData.ChangeCoin(Main.Instance.saveData.LevelIndex * 200 * 2);
            Hide();
            Main.Instance.DestoryOldScene();
            Main.Instance.CreateNewScene();
            Sequence sequence = DOTween.Sequence();
            sequence.Append(text.transform.DOMoveY(text.transform.position.y - (Screen.height / 2), 2.5f).SetEase(Ease.OutQuad));
            sequence.AppendInterval(1f);
            sequence.Append(text.transform.DOMoveY(text.transform.position.y, 2f).SetEase(Ease.InQuad));
            sequence.OnComplete(() =>
            {
                UIManager.Instance.CreateOrOpen(PanelId.MainMenu);
            });
        });

    }
}
